<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>qLibc: ipc/qsem.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">qLibc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('qsem_8c.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">qsem.c File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Semaphore APIs.  
<a href="#details">More...</a></p>

<p><a href="qsem_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ac66cb18076dd21f67ac4b9a5b246d2d2"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#ac66cb18076dd21f67ac4b9a5b246d2d2">qsem_init</a> (const char *keyfile, int keyid, int nsems, bool recreate)</td></tr>
<tr class="memdesc:ac66cb18076dd21f67ac4b9a5b246d2d2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize semaphore.  <br /></td></tr>
<tr class="separator:ac66cb18076dd21f67ac4b9a5b246d2d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aac470476fa8ecdc4cd9ec9596d3d6ca4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#aac470476fa8ecdc4cd9ec9596d3d6ca4">qsem_getid</a> (const char *keyfile, int keyid)</td></tr>
<tr class="memdesc:aac470476fa8ecdc4cd9ec9596d3d6ca4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get semaphore identifier by keyfile and keyid for the existing semaphore.  <br /></td></tr>
<tr class="separator:aac470476fa8ecdc4cd9ec9596d3d6ca4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acd893b0a1a6b390f27621ae0e93a5dd8"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#acd893b0a1a6b390f27621ae0e93a5dd8">qsem_enter</a> (int semid, int semno)</td></tr>
<tr class="memdesc:acd893b0a1a6b390f27621ae0e93a5dd8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Turn on the flag of semaphore then entering critical section.  <br /></td></tr>
<tr class="separator:acd893b0a1a6b390f27621ae0e93a5dd8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5993822d89f9f6f36ffcedf95a921be0"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#a5993822d89f9f6f36ffcedf95a921be0">qsem_enter_nowait</a> (int semid, int semno)</td></tr>
<tr class="memdesc:a5993822d89f9f6f36ffcedf95a921be0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to turn on the flag of semaphore.  <br /></td></tr>
<tr class="separator:a5993822d89f9f6f36ffcedf95a921be0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a023df7733cebc81fc0aa0285772a914d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#a023df7733cebc81fc0aa0285772a914d">qsem_enter_force</a> (int semid, int semno, int maxwaitms, bool *forceflag)</td></tr>
<tr class="memdesc:a023df7733cebc81fc0aa0285772a914d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Force to turn on the flag of semaphore.  <br /></td></tr>
<tr class="separator:a023df7733cebc81fc0aa0285772a914d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4904a3e477119a2cf177a23068a58fdd"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#a4904a3e477119a2cf177a23068a58fdd">qsem_leave</a> (int semid, int semno)</td></tr>
<tr class="memdesc:a4904a3e477119a2cf177a23068a58fdd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Turn off the flag of semaphore then leaving critical section.  <br /></td></tr>
<tr class="separator:a4904a3e477119a2cf177a23068a58fdd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac56cd066622f8e9bc669c70e51e8a378"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#ac56cd066622f8e9bc669c70e51e8a378">qsem_check</a> (int semid, int semno)</td></tr>
<tr class="memdesc:ac56cd066622f8e9bc669c70e51e8a378"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the status of semaphore.  <br /></td></tr>
<tr class="separator:ac56cd066622f8e9bc669c70e51e8a378"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab73d1cc1e7a82ce1b4b119ff56d25011"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsem_8c.html#ab73d1cc1e7a82ce1b4b119ff56d25011">qsem_free</a> (int semid)</td></tr>
<tr class="memdesc:ab73d1cc1e7a82ce1b4b119ff56d25011"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release semaphore to system.  <br /></td></tr>
<tr class="separator:ab73d1cc1e7a82ce1b4b119ff56d25011"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Semaphore APIs. </p>
<dl class="section note"><dt>Note</dt><dd><div class="fragment"><div class="line">[daemon main]</div>
<div class="line"><span class="preprocessor">#define MAX_SEMAPHORES (2)</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// create semaphores</span></div>
<div class="line"><span class="keywordtype">int</span> semid = <a class="code hl_function" href="qsem_8c.html#ac66cb18076dd21f67ac4b9a5b246d2d2">qsem_init</a>(<span class="stringliteral">&quot;/some/file/for/generating/unique/key&quot;</span>, <span class="charliteral">&#39;q&#39;</span>, MAX_SEMAPHORES, <span class="keyword">true</span>);</div>
<div class="line"><span class="keywordflow">if</span>(semid &lt; 0) {</div>
<div class="line">  printf(<span class="stringliteral">&quot;ERROR: Can&#39;t initialize semaphores.\n&quot;</span>);</div>
<div class="line">  <span class="keywordflow">return</span> -1;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// fork childs</span></div>
<div class="line">(... child forking codes ...)</div>
<div class="line"> </div>
<div class="line"><span class="comment">// at the end of daemon, free semaphores</span></div>
<div class="line"><span class="keywordflow">if</span>(semid &gt;= 0) <a class="code hl_function" href="qsem_8c.html#ab73d1cc1e7a82ce1b4b119ff56d25011">qsem_free</a>(semid);</div>
<div class="line"> </div>
<div class="line">[forked child]</div>
<div class="line"><span class="comment">// critical section for resource 0</span></div>
<div class="line"><a class="code hl_function" href="qsem_8c.html#acd893b0a1a6b390f27621ae0e93a5dd8">qsem_enter</a>(semid, 0);</div>
<div class="line">(... guaranteed as atomic procedure ...)</div>
<div class="line"><a class="code hl_function" href="qsem_8c.html#a4904a3e477119a2cf177a23068a58fdd">qsem_leave</a>(semid, 0);</div>
<div class="line"> </div>
<div class="line">(... some codes ...)</div>
<div class="line"> </div>
<div class="line"><span class="comment">// critical section for resource 1</span></div>
<div class="line"><a class="code hl_function" href="qsem_8c.html#acd893b0a1a6b390f27621ae0e93a5dd8">qsem_enter</a>(semid, 1);</div>
<div class="line">(... guaranteed as atomic procedure ...)</div>
<div class="line"><a class="code hl_function" href="qsem_8c.html#a4904a3e477119a2cf177a23068a58fdd">qsem_leave</a>(semid, 1);</div>
<div class="line"> </div>
<div class="line">[other program which uses resource 1]</div>
<div class="line"><span class="keywordtype">int</span> semid = <a class="code hl_function" href="qsem_8c.html#aac470476fa8ecdc4cd9ec9596d3d6ca4">qsem_getid</a>(<span class="stringliteral">&quot;/some/file/for/generating/unique/key&quot;</span>, <span class="charliteral">&#39;q&#39;</span>);</div>
<div class="line"><span class="keywordflow">if</span>(semid &lt; 0) {</div>
<div class="line">  printf(<span class="stringliteral">&quot;ERROR: Can&#39;t get semaphore id.\n&quot;</span>);</div>
<div class="line">  <span class="keywordflow">return</span> -1;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="comment">// critical section for resource 1</span></div>
<div class="line"><a class="code hl_function" href="qsem_8c.html#acd893b0a1a6b390f27621ae0e93a5dd8">qsem_enter</a>(semid, 1);</div>
<div class="line">(... guaranteed as atomic procedure ...)</div>
<div class="line"><a class="code hl_function" href="qsem_8c.html#a4904a3e477119a2cf177a23068a58fdd">qsem_leave</a>(semid, 1);</div>
<div class="ttc" id="aqsem_8c_html_a4904a3e477119a2cf177a23068a58fdd"><div class="ttname"><a href="qsem_8c.html#a4904a3e477119a2cf177a23068a58fdd">qsem_leave</a></div><div class="ttdeci">bool qsem_leave(int semid, int semno)</div><div class="ttdoc">Turn off the flag of semaphore then leaving critical section.</div><div class="ttdef"><b>Definition</b> <a href="qsem_8c_source.html#l00263">qsem.c:263</a></div></div>
<div class="ttc" id="aqsem_8c_html_aac470476fa8ecdc4cd9ec9596d3d6ca4"><div class="ttname"><a href="qsem_8c.html#aac470476fa8ecdc4cd9ec9596d3d6ca4">qsem_getid</a></div><div class="ttdeci">int qsem_getid(const char *keyfile, int keyid)</div><div class="ttdoc">Get semaphore identifier by keyfile and keyid for the existing semaphore.</div><div class="ttdef"><b>Definition</b> <a href="qsem_8c_source.html#l00155">qsem.c:155</a></div></div>
<div class="ttc" id="aqsem_8c_html_ab73d1cc1e7a82ce1b4b119ff56d25011"><div class="ttname"><a href="qsem_8c.html#ab73d1cc1e7a82ce1b4b119ff56d25011">qsem_free</a></div><div class="ttdeci">bool qsem_free(int semid)</div><div class="ttdoc">Release semaphore to system.</div><div class="ttdef"><b>Definition</b> <a href="qsem_8c_source.html#l00298">qsem.c:298</a></div></div>
<div class="ttc" id="aqsem_8c_html_ac66cb18076dd21f67ac4b9a5b246d2d2"><div class="ttname"><a href="qsem_8c.html#ac66cb18076dd21f67ac4b9a5b246d2d2">qsem_init</a></div><div class="ttdeci">int qsem_init(const char *keyfile, int keyid, int nsems, bool recreate)</div><div class="ttdoc">Initialize semaphore.</div><div class="ttdef"><b>Definition</b> <a href="qsem_8c_source.html#l00102">qsem.c:102</a></div></div>
<div class="ttc" id="aqsem_8c_html_acd893b0a1a6b390f27621ae0e93a5dd8"><div class="ttname"><a href="qsem_8c.html#acd893b0a1a6b390f27621ae0e93a5dd8">qsem_enter</a></div><div class="ttdeci">bool qsem_enter(int semid, int semno)</div><div class="ttdoc">Turn on the flag of semaphore then entering critical section.</div><div class="ttdef"><b>Definition</b> <a href="qsem_8c_source.html#l00180">qsem.c:180</a></div></div>
</div><!-- fragment --> </dd></dl>

<p class="definition">Definition in file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ac66cb18076dd21f67ac4b9a5b246d2d2" name="ac66cb18076dd21f67ac4b9a5b246d2d2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac66cb18076dd21f67ac4b9a5b246d2d2">&#9670;&#160;</a></span>qsem_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int qsem_init </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>keyfile</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>keyid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>nsems</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>recreate</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize semaphore. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">keyfile</td><td>seed for generating unique IPC key </td></tr>
    <tr><td class="paramname">keyid</td><td>seed for generating unique IPC key </td></tr>
    <tr><td class="paramname">nsems</td><td>number of semaphores to initialize </td></tr>
    <tr><td class="paramname">recreate</td><td>set to true to re-create semaphore if exists</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>non-negative shared memory identifier if successful, otherwise returns -1</dd></dl>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> semid = <a class="code hl_function" href="qsem_8c.html#ac66cb18076dd21f67ac4b9a5b246d2d2">qsem_init</a>(<span class="stringliteral">&quot;/tmp/mydaemon.pid&quot;</span>, <span class="charliteral">&#39;q&#39;</span>, 10, <span class="keyword">true</span>);</div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00102">102</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
<a id="aac470476fa8ecdc4cd9ec9596d3d6ca4" name="aac470476fa8ecdc4cd9ec9596d3d6ca4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aac470476fa8ecdc4cd9ec9596d3d6ca4">&#9670;&#160;</a></span>qsem_getid()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int qsem_getid </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>keyfile</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>keyid</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get semaphore identifier by keyfile and keyid for the existing semaphore. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">keyfile</td><td>seed for generating unique IPC key </td></tr>
    <tr><td class="paramname">keyid</td><td>seed for generating unique IPC key</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>non-negative shared memory identifier if successful, otherwise returns -1 </dd></dl>

<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00155">155</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
<a id="acd893b0a1a6b390f27621ae0e93a5dd8" name="acd893b0a1a6b390f27621ae0e93a5dd8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acd893b0a1a6b390f27621ae0e93a5dd8">&#9670;&#160;</a></span>qsem_enter()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qsem_enter </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semno</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Turn on the flag of semaphore then entering critical section. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semid</td><td>semaphore identifier </td></tr>
    <tr><td class="paramname">semno</td><td>semaphore number</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false</dd></dl>
<dl class="section note"><dt>Note</dt><dd>If the semaphore is already turned on, this will wait until released </dd></dl>

<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00180">180</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
<a id="a5993822d89f9f6f36ffcedf95a921be0" name="a5993822d89f9f6f36ffcedf95a921be0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5993822d89f9f6f36ffcedf95a921be0">&#9670;&#160;</a></span>qsem_enter_nowait()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qsem_enter_nowait </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semno</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Try to turn on the flag of semaphore. </p>
<p>If it is already turned on, do not wait.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semid</td><td>semaphore identifier </td></tr>
    <tr><td class="paramname">semno</td><td>semaphore number</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise(already turned on by other) returns false </dd></dl>

<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00202">202</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
<a id="a023df7733cebc81fc0aa0285772a914d" name="a023df7733cebc81fc0aa0285772a914d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a023df7733cebc81fc0aa0285772a914d">&#9670;&#160;</a></span>qsem_enter_force()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qsem_enter_force </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semno</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>maxwaitms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool *&#160;</td>
          <td class="paramname"><em>forceflag</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Force to turn on the flag of semaphore. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semid</td><td>semaphore identifier </td></tr>
    <tr><td class="paramname">semno</td><td>semaphore number </td></tr>
    <tr><td class="paramname">maxwaitms</td><td>maximum waiting micro-seconds to release </td></tr>
    <tr><td class="paramname">forceflag</td><td>status will be stored, it can be NULL if you don't need this information</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false</dd></dl>
<dl class="section note"><dt>Note</dt><dd>This will wait the semaphore to be released with in maxwaitms. If it it released by locker normally with in maxwaitms, forceflag will be set to false. But if maximum maxwaitms is exceed and the semaphore is released forcely, forceflag will be set to true. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00232">232</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
<a id="a4904a3e477119a2cf177a23068a58fdd" name="a4904a3e477119a2cf177a23068a58fdd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4904a3e477119a2cf177a23068a58fdd">&#9670;&#160;</a></span>qsem_leave()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qsem_leave </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semno</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Turn off the flag of semaphore then leaving critical section. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semid</td><td>semaphore identifier </td></tr>
    <tr><td class="paramname">semno</td><td>semaphore number</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false </dd></dl>

<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00263">263</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
<a id="ac56cd066622f8e9bc669c70e51e8a378" name="ac56cd066622f8e9bc669c70e51e8a378"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac56cd066622f8e9bc669c70e51e8a378">&#9670;&#160;</a></span>qsem_check()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qsem_check </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semno</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the status of semaphore. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semid</td><td>semaphore identifier </td></tr>
    <tr><td class="paramname">semno</td><td>semaphore number</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true for the flag on, false for the flag off </dd></dl>

<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00285">285</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
<a id="ab73d1cc1e7a82ce1b4b119ff56d25011" name="ab73d1cc1e7a82ce1b4b119ff56d25011"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab73d1cc1e7a82ce1b4b119ff56d25011">&#9670;&#160;</a></span>qsem_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qsem_free </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>semid</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Release semaphore to system. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semid</td><td>semaphore identifier</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false </dd></dl>

<p class="definition">Definition at line <a class="el" href="qsem_8c_source.html#l00298">298</a> of file <a class="el" href="qsem_8c_source.html">qsem.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_b94456e2763cc4ff61641ee1fd517631.html">ipc</a></li><li class="navelem"><a class="el" href="qsem_8c.html">qsem.c</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 </li>
  </ul>
</div>
</body>
</html>
